﻿using System.Collections;
using System.Collections.Generic;
using Entitas;
using Entitas.Unity;
using UnityEngine;

public class View : MonoBehaviour,IView,IComponentsDestroyListener
{
    //TODO:继承DestroyListener
    
    // Start is called before the first frame update
    protected GameEntity _gameEntity;
    public virtual void OnComponentsDestroy(GameEntity entity)
    {
        gameObject.Unlink();

    }

    public virtual void Link(IEntity entity, IContext context)
    {
        if (entity is GameEntity)
        {
            _gameEntity= entity as GameEntity;
        }
        else
        {
            Debug.Log("实体类型错误");
            return;
        }

        gameObject.Link(entity);
    }
}
